<?php
include_once('admin_global.php');
bn_include_lib('bn_jquery');
$theme->add_block('body');
$rn=new bn_rolname;
$rol=new bn_rol;
$theme->add_script(jquery_select('#rolenameddl',array('afpost'=>'$("#show").html(data)')));
$theme->add_script(jquery_element(':checkbox','click','
var val=$("#rolenameddl").val();
var path=$(this).val();
var ch="uncheck";
if($(this).is(":checked"))
ch="check";

$.post(window.location.href,{cmd:"rol",rn:val,path:path,is:ch});
'));

$cmd=$_POST['cmd'];
if(isset($cmd))
{
    if($cmd=='#rolenameddl')
    die('<table>
    <tr>
	    <td>'.$rol->List_ppage($_POST['value']).'</td>
	    <td>'.$rol->List_vpage($_POST['value']).'</td>
	    <td>'.$rol->list_modulepage($_POST['value']).'</td>
    </tr>
    </table>
    ');
    
    if($cmd=='rol')
    {
        $rn=$_POST['rn'];
        if($_POST['is']=='check')
        {
            $path=str_replace('\\','/',$_SERVER['DOCUMENT_ROOT']);
            $rol->insert($rn,str_replace($path,'',$_POST['path']));
            die;   
        } 
        else
        {
           $path=str_replace('\\','/',$_SERVER['DOCUMENT_ROOT']);
           $rol->delete($rn,str_replace($path,'',$_POST['path']));
           die; 
        }
    }
}
?>
<label><?php echo $lang[73] ?></label>
<?php
echo $rn->ddl_rolename();	
?>
<div id="show">
<table>
<tr>
	<td>
    <?php
	echo $rol->List_ppage(2);
    ?>
    </td>
	<td>
    <?php
	echo $rol->List_vpage(2);
    ?>
    </td>
	<td>
    <?php
	echo $rol->list_modulepage(2);
    ?>
    </td>
</tr>
</table>
</div>
<?php
$theme->render();
?>